'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { merchant_commentService } from '../service/merchant_comment';

/** 评价API对象 */
@prefix('mercomment')
class Merchant_commentController {
    /**
     * @api {post} /mercomment/query  查询商户评价列表
     * @apiDescription 查询商户评价列表
     * @apiName query
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiParam (参数) {String} mid    商户_id
     * @apiSampleRequest /mercomment/query
     * @apiGroup mercomment
     * @apiVersion 1.0.0
     */
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await merchant_commentService.query(ctx.request.body);
        response(ctx, result);
    }
    /**
     * @api {post} /mercomment/save  保存评价
     * @apiDescription 保存评价
     * @apiName save
     * @apiParam (参数) {String} orderCode   订单编号orderCode
     * @apiParam (参数) {Number} star   评价星级
     * @apiParam (参数) {String} content  评价内容
     * @apiParam (参数) {Array} lables  评价标签数组
     * @apiParam (参数) {Array} imgs  评价图片数组
     * @apiSampleRequest /mercomment/save
     * @apiGroup mercomment
     * @apiVersion 2.0.0
     */
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await merchant_commentService.save(ctx.request.body);
        response(ctx, result);
    }
}